package com.luozhili.Swing;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * button 和 dialog 练习
 */
public class Demo4 extends JFrame  {
    JLabel label1;
    JButton jButton;
    JFrame frame=this;
    public Demo4() {
        Container c = this.getContentPane();

        JLabel jLabel = new JLabel("1234");
        c.add(jLabel);

        JButton jButton = new JButton("显示对话框");
        //添加时间监听器，弹出dialog窗体
        jButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Dialog1 dialog1 = new Dialog1();
//                Dialog1 dialog1 = new Dialog1(frame);
                dialog1.setVisible(true);

            }
        });
        c.add(jButton);

        c.setLayout(new FlowLayout());
        this.setSize(300,150);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
    }



    public static void main(String[] args) {
        new Demo4();

    }
}
